
//banner轮播图
var banner = new Swiper('.first-screen-banner .swiper-container', {
  // direction: 'horizontal', // 水平切换选项
  loop: true, // 循环模式选项
  autoplay: true,

  // 如果需要分页器
  pagination: {
    el: '.swiper-pagination',
  }
})

//news
var news = new Swiper('.first-screen-news .swiper-container', {
  direction: 'vertical', // 垂直切换选项
  loop: true, // 循环模式选项
  autoplay: true
})


//group-floor1
function gf1sendAjax() {
  $.ajax({
    type: "get",
    url: "../api/group-floor1.json",
    dataType: "json",
    success(data) {
      let htmlStr = "";
      data.forEach((item) => {
        // console.log(item)
        htmlStr += `
        <a href="javascript:;" class="titlePic">
          <img src="${item.titlePic}" alt="">
        </a>
        <div class="product-list">
        
          `
          $(item.proList).forEach((item1)=>{
            htmlStr += `
            <div class="proitem">
            <div class="pic">
                  <a href="javascript:;">
                    <img src="${item1.pic}" alt="">
                  </a>
                  <div class="saletip">`
                  if(item1.desc!=""){
                    htmlStr+=`<span>${item1.desc}</span>`
                  }
                  htmlStr+=`</div>
                </div>
                <div class="info">
                  <p class="name">
                    <a href="javascript:;">${item1.tilte}</a>
                  </p>
                  <div class="price">
                    <strong>${item1.price}</strong>
                    <i class="iconfont icon-icon-"></i>
                  </div>
                </div>
              </div>
              `
            })
            htmlStr += `
              </div>
            `
      })
      $(".group-floor1").html(htmlStr);
        }
      })
}
gf1sendAjax();


//one-image
function oisendAjax() {
  $.ajax({
    type: "get",
    url: "../api/one-image.json",
    dataType: "json",
    success(data) {
      // console.log(data);
      let htmlStr = "";
      // let htmlStr1 = "";
      // let srcList = data;
      // console.log(srcList)
      // htmlStr += `
      // <div class="one-image">
      //   `
      data.forEach((item) => {
        
        htmlStr +=`
       
        <a href="javascript:;" class="link-img">
          <img src="${item.linkPic}" alt="">
        </a>
        `
        // htmlStr += `
        // </div>
        //   `
      })
      $(".one-image").html(htmlStr);
        }
      })
}
oisendAjax();

//group-floor
function gfsendAjax() {
  $.ajax({
    type: "get",
    url: "../api/group-floor.json",
    dataType: "json",
    success(data) {
      // console.log(data);
      let htmlStr = "";
      // let htmlStr1 = "";
      // let srcList = data;
      // console.log(srcList)
      data.forEach((item) => {
        htmlStr += `
        <a href="javascript:;" class="titlePic">
          <img src="${item.titlePic}" alt="">
        </a>
        <div class="product-list">
        
          `
          $(item.proList).forEach((item1)=>{
            htmlStr += `
            <div class="proitem">
            <div class="pic">
                  <a href="javascript:;">
                    <img src="${item1.pic}" alt="">
                  </a>
                  <div class="saletip">`
                  if(item1.desc!=""){
                    htmlStr+=`<span>${item1.desc}</span>`
                  }
                  htmlStr+=`</div>
                </div>
                <div class="info">
                  <p class="name">
                    <a href="javascript:;">${item1.tilte}</a>
                  </p>
                  <div class="price">
                    <strong>${item1.price}</strong>
                    <i class="iconfont icon-icon-"></i>
                  </div>
                </div>
              </div>
              `
            })
            htmlStr += `
                <a href="javascript:;" class="more">
                  <p class="hot">
                    查看更多
                    <i class="iconfont icon-rightarrow"></i>
                  </p>
                </a>
              </div>
            `
      })
      $(".group-floor").html(htmlStr);
        }
      })
}
gfsendAjax();



//proList
function pro1sendAjax() {
  $.ajax({
    type: "get",
    url: "../api/homeProlist.json",
    dataType: "json",
    success(data) {
      let htmlStr = "";
      
      data.forEach((item) => {
        // console.log(item)
        htmlStr += `
        <div class="blockwrap prolist-blockwrap">
     
      <ul>
        <li>
          <div class="proitem">
            <div class="pic">
              <a href="javascript:;">
                <img src="${item.src}">
              </a>
            </div>
            <div class="info">
              <div class="info-wrap">
                <p class="name">
                  <a href="javascript:;">${item.title}</a>
                </p>
                <p class="sub">`
                if(item.saletip!=""){
                  htmlStr+=`<span class="saletip">
                    <span>${item.saletip}</span>
                  </span>`
                }
                htmlStr+=`
                   ${item.saletipTitle}
                
              </p>
               </div>
              <div class="price pricePadding"><strong>${item.price}</strong>
                /${item.priceIndex}
                <i class="iconfont icon-icon-"></i></div>
            </div>
          </div>
        </li>
      </ul>
    </div>
              `
          
           
            })
            $(".prolist").html(htmlStr);
    }
  })
}
pro1sendAjax();


//prolist2
function pro2sendAjax() {
  $.ajax({
    type: "get",
    url: "../api/homeProlistBackground.json",
    dataType: "json",
    success(data) {
      let htmlStr = "";
      
      data.forEach((item,index) => {
        // console.log(item)
        htmlStr += `
        <div class="blockwrap">
        <div class="tt">
            <h3>${item.title}</h3>
        </div>
        <ul class="twoproduct">
            <!---->
          `
          $(item.content).forEach((item1)=>{
            htmlStr += `
            <li>
            <div class="proitem">
            <div class="pic">
                  <a href="javascript:;">
                    <img src="${item1.src}" alt="">
                  </a>
                  <div class="saletip">`
                  if(item1.saletip!=""){
                    htmlStr+=`<span>${item1.saletip}</span>`
                  }
                  htmlStr+=`</div>
                </div>
                <div class="info">
                  <p class="name">
                    <a href="javascript:;">${item1.name}</a>
                  </p>
                  <div class="price">
                    <strong>${item1.price}</strong>
                    ${item1.num}
                    <i class="iconfont icon-icon-"></i>
                  </div>
                </div>
              </li>
              `
            })
            htmlStr += `
            </ul>
              </div>
            `
            $(".prolist2").html(htmlStr);
      })
    }
  })
}
pro2sendAjax();

//footer
// function footer(){
  var aList = document.querySelectorAll(".footer a");
  // console.log(aList)
  for(var i = 0;i < aList.length; i++){
    aList[i].onclick = function(){
      // console.log(1)
      this.classList.add("active");
    }
  }
// }
// footer();

